<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ page
	import="com.onlineMIS.common.Common_util,java.util.Date,java.text.SimpleDateFormat"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>千禧宝贝连锁店管理信息系统</title>
<%@ include file="../../common/Style.jsp"%>
<SCRIPT src="<%=request.getContextPath()%>/conf_files/js/ChainReport.js"
	type=text/javascript></SCRIPT>
<script
	src="<%=request.getContextPath()%>/conf_files/js/highChart/js/highcharts.js"></script>
<script
	src="<%=request.getContextPath()%>/conf_files/js/highChart/js/modules/exporting.js"></script>
<script
	src="<%=request.getContextPath()%>/conf_files/js/drawHighChartSales.js"></script>
<script src="<%=request.getContextPath()%>/conf_files/js/echarts/echarts.min.js"></script>

<script>

$(document).ready(function(){
	parent.$.messager.progress('close'); 
	var params = $.serializeObject($('#preGenReportForm')); 
	dataGrid = $('#dataGrid').datagrid({
		url : 'chainReportJSON!generateEchartsReport',
		queryParams: params,
		fit : true,
		border : false,
		pagination : false,
		pageSize : 20,		
		checkOnSelect : false,
		selectOnCheck : false,
		singleSelect:true,
		nowrap : false,
		rownumbers : true,
		columns : [ [ 
		              
			{
				field : 'dateTime',
				title : '时间',
				width : 180
			},{
				field : 'beforeQuantity',
				title : '上一年同期净销量A',
				width : 150
			},{	
				field : 'beforeAmount',
				title : '上一年同期净销售额B',
				width : 170			
			},{				
				field : 'todayQuantity',
				title : '今年净销量C',
				width : 250
			},{						
				field : 'todayAmount',
				title : '今年净销售额D',
				width : 250
		    },{				
				field : 'differQuantity',
				title : '净销量差值C-A',
				width : 300
			},{				
				field : 'differAmount',
				title : '净销售额差值D-B',
				width : 300
			}]],
			toolbar : '#toolbar'

	});
});


function generateEchartsReport(){	
	var echartsType = $("#echartsType").val();
	if(echartsType == -1 || echartsType == null){
		$.messager.alert('提示', '请选择需要查询的报表类型', 'warning');
	}else{
		var params = $.serializeObject($('#preGenReportForm')); 
		$('#dataGrid').datagrid('load',params); 
	}					
}


/**
 * 连锁店点击回调方法
 */
function changeChainStore(chainId){
	var params = "formBean.chainStore.chain_id=" + chainId;
	$.post("<%=request.getContextPath()%>/actionChain/chainMgmtJSON!changeChainStore",params, backProcessChangeChainStore,"json");
}

function backProcessChangeChainStore(data){
	
	var users =  data.chainUsers;
	if (users != undefined){
		$("#chainSaler").empty();
		
		$("#chainSaler").append("<option value='<%=Common_util.ALL_RECORD%>'>---全部---</option>"); 
		
		for (var i = 0; i < users.length; i++)
			   $("#chainSaler").append("<option value='"+users[i].user_id+"'>"+users[i].name+"</option>"); 
	}
}


</script>
</head>
<body>
<div class="easyui-layout" data-options="fit : true,border : false">
		<div data-options="region:'north',border:false"
			style="height: 153px; overflow: hidden;">
  <s:form id="preGenReportForm" action="/actionChain/chainReportJSPAction!generateReport" theme="simple" method="POST"> 
     <s:hidden name="formBean.reportType" id="reportType"/>
     <table width="100%" align="center"  class="OuterTable">
	    <tr><td>
			 <table width="100%" border="0">
			    <tr>
			       <td height="50" colspan="7">
					   <table width="100%" border="0">
					    <tr class="InnerTableContent">
					      <td width="45" height="30">&nbsp;</td>
					      <td width="76"><strong>单据日期</strong></td>
					      <td width="284" colspan="2">
					        <s:textfield id="startDate" name="formBean.startDate" cssClass="easyui-datebox"  data-options="width:100,editable:false"/>
					        &nbsp;至&nbsp;
					        <s:textfield id="endDate" name="formBean.endDate" cssClass="easyui-datebox" data-options="width:100,editable:false"/>
					      </td>
					      <td></td>
					    </tr>
						<tr class="InnerTableContent">
					      <td height="30">&nbsp;</td>
					      <td><strong>连锁店</strong></td>
					      <td><%@ include file="../include/SearchChainStore.jsp"%></td>
					      <td></td>
					      <td></td>
					    </tr>
					    <tr class="InnerTableContent">
					      <td height="30">&nbsp;</td>
					      <td><strong>经手人</strong></td>
					      <td><s:select id="chainSaler" cssClass="easyui-combobox" style="width:120px;text-align: center" editable="false"  name="formBean.saler.user_id"  list="uiBean.chainSalers" listKey="user_id" listValue="name" headerKey="-1" headerValue="-----全选-----"/></td>
					      <td></td>
					      <td></td>
					    </tr>
					     <tr class="InnerTableContent">
					      <td height="30">&nbsp;</td>
					      <td><strong>报表类型</strong></td>
					      <td><select id="echartsType" name="formBean.echartsType" editable="false" class="easyui-combobox" style="width:150px;">
					      		<option value="-1">---请选择报表类型--</option>
								<option value="0">日报表</option>
								<option value="1">周报表</option>
								<option value="2">月报表</option>
					      </select></td>
					      <td></td>
					      <td></td>
					    </tr>
	                   
					  </table></td>
			    </tr>
					</table>
				</td>
			</tr>

	 </table>
	 </s:form>
	 </div>
	 
	 <div data-options="region:'center',border:false"> 	
			<table id="dataGrid">
			</table>

			<div id="toolbar" style="display: none;">
				<a onclick="generateEchartsReport();" href="javascript:void(0);"
					class="easyui-linkbutton"
					data-options="iconCls:'icon-search',plain:true">查询报表</a>  
			</div>
		</div>
	 
</div>	 
	 



</body>
</html>